package day06test;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        //1. 评委打分案例
        double[] scores=inputScores(5);
        double avg=getAverage(scores);
        System.out.println("avg: "+avg);
    }
    public static double[] inputScores(int n){
        Scanner scan=new Scanner(System.in);
        double[] scores=new double[n];
        for (int i=0;i<scores.length;i++){
            System.out.println("请输入第"+(i+1)+"个评委的打分：");
            scores[i]=scan.nextDouble();
        }
        return scores;
    }
    public static double getAverage(double[] scores){
        double avg=0.0;
        double sum=0.0;
        double max=scores[0];
        double min=scores[0];
        for (int i=0;i<scores.length;i++){
            sum+=scores[i];
            if (scores[i]>max){
                max=scores[i];
            }
            if (scores[i]<min){
                min=scores[i];
            }
        }
        avg=(sum-max-min)/(scores.length-2);
        return avg;
    }
}
